﻿@inject IOptionsSnapshot<SiteOptions> SiteOptions
@model BlogPostDetails

@{
    var content = Model?.Content?.Convert2Html();
}

<div class="left-box">
    <div class="whitebg">
        <div class="news-title">
            <span class="weizhi">联系请关注微信公众号：Dotnet9</span>
            <h2>文章</h2>
        </div>
        <div class="newstext-box">
            <div id="nice">
                <h1 class="news-title-h1">@Model?.Title</h1>
            </div>
            @if (Model?.Tags is { Count: > 0 })
            {
                <div class="keywords">
                    @foreach (var blogTag in Model.Tags)
                    {
                        <a target="_blank" href="/tag/@blogTag">@blogTag</a>
                    }
                </div>
            }
            <div class="picview-other">
                <span class="po-from">@(Model?.Original ?? @SiteOptions.Value.Owner)</span>
                <span class="po-date">@Model?.CreationTime.ToString("yyyy-MM-dd HH:mm:ss")</span>
                @if (Model?.Albums is { Count: > 0 })
                {
                    <label>- 专辑：</label>
                    @foreach (var blogAlbum in Model.Albums)
                    {
                        <span class="po-classname">
                            <a target="_blank" href="/album/@blogAlbum.Slug">@blogAlbum.Name</a>
                        </span>
                    }
                }
                @if (Model?.Categories is { Count: > 0 })
                {
                    <label>- 分类：</label>
                    @foreach (var blogCat in Model.Categories)
                    {
                        <span class="po-classname">
                            <a target="_blank" href="/cat/@blogCat.Slug">@blogCat.Name</a>
                        </span>
                    }
                }
                <span class="po-view">@Model?.ViewCount</span>
            </div>
            <div class="smalltext">
                <i></i>@Model?.Description
            </div>
            @if (!content.IsNullOrWhiteSpace())
            {
                <div id="nice">@Html.Raw(content)</div>
            }
            <div class="diggit" style="cursor: pointer">
                <a>很赞哦！</a>(<b id="diggnum">@Model?.LikeCount</b>)
                <input class="blogslug" value="@Model?.Slug" type="hidden"/>
            </div>
            <div class="clear"></div>
            <div class="share" id="down">
                <img src="@SiteOptions.Value.WechatPublic1" alt="">
                <div class="share-text">
                    <p>扫码关注@(SiteOptions.Value.WechatPublic1Name)微信公众号，第一时间获取网站更新动态</p>
                    @switch (Model?.CopyrightType)
                    {
                        case CopyRightType.Reprint:
                            <p>本文来自转载，如若二次转载请联系原作者。</p>
                            break;
                        case CopyRightType.Contribution:
                            <p>本文来自网友投稿，如若转载请联系原作者。</p>
                            break;
                        default:
                            <p>本文由本站(<a href="@SiteOptions.Value.Domain">@SiteOptions.Value.Domain</a>)整理或创作，如若转载请保留原文标题及原文链接</p>
                            break;
                    }
                    <p>原文作者：<a style="color: #262626;" href="#">@(Model?.Original ?? @SiteOptions.Value.Owner)</a></p>
                    @if (Model?.CopyrightType == CopyRightType.Default)
                    {
                        <p>原文标题：<a href="/@Model.CreationTime.ToString("yyyy/MM")/@Model.Slug">@Model.Title</a></p>
                        <p>原文链接：<a href="/@Model.CreationTime.ToString("yyyy/MM")/@Model.Slug">@SiteOptions.Value.Domain/@($"{Model.CreationTime:yyyy/MM}/{Model.Slug}")</a></p>
                    }
                    else
                    {
                        <p>原文标题：<a href="@Model?.OriginalLink">@(Model?.OriginalTitle ?? Model?.Title)</a></p>
                        <p>原文链接：<a href="@Model?.OriginalLink">@Model?.OriginalLink</a></p>
                    }
                </div>
            </div>
            <div class="clear"></div>
            <div class="info-pre-next">
                <ul>
                    @if (Model?.Preview != null)
                    {
                        <li>
                            <a href="/@Model.Preview.CreationTime.ToString("yyyy/MM")/@Model.Preview.Slug">
                                <i>
                                    <em>上一篇</em><img alt="@Model.Preview.Title" src="@Model.Preview.Cover">
                                </i>
                                <h2>@Model.Preview.Title</h2>
                                <p>@Model.Preview.Description</p>
                            </a>
                        </li>
                    }
                    @if (Model?.Next != null)
                    {
                        <li>
                            <a href="/@Model.Next.CreationTime.ToString("yyyy/MM")/@Model.Next.Slug">
                                <i>
                                    <em>下一篇</em><img alt="@Model.Next.Title" src="@Model.Next.Cover">
                                </i>
                                <h2>@Model.Next.Title</h2>
                                <p>@Model.Next.Description</p>
                            </a>
                        </li>
                    }
                </ul>
            </div>
        </div>
    </div>
    <environment names="Production">
        @*@await Html.PartialAsync("Ads/_DiaplayPartial")*@
    </environment>
    <div class="clear blank"></div>
    @if (Model?.Nears is { Count: > 0 })
    {
        <div class="otherlink whitebg">
            <div class="news-title">
                <h2>相关文章</h2>
            </div>
            <ul>
                @foreach (var post in Model.Nears.RandomItems(10))
                {
                    <li>
                        <a target="_blank" href="/@post.CreationTime.ToString("yyyy/MM")/@post.Slug">@post.Title</a>
                    </li>
                }
            </ul>
        </div>
    }
    <div class="clear blank"></div>
    <div class="pinglun-box whitebg">
        @*@await Html.PartialAsync("Comments/_CommentsPartial", new CommentViewModel($"/{Model.Year}/{Model.Month}/{Model.Slug}"))*@
    </div>
</div>
<aside class="side-section right-box">

    <environment names="Production">
        @*@await Html.PartialAsync("Ads/_DiaplayPartial")*@
    </environment>
    <div class="clear blank"></div>
    @await Html.PartialAsync("Sides/_TuiJianAndTopPartial")
    <div class="clear blank"></div>
    <environment names="Production">
        @*@await Html.PartialAsync("Ads/_DiaplayPartial")*@
    </environment>
    <div class="clear blank"></div>
    @await Html.PartialAsync("Sides/_TagCloudsPartial")
    <div class="clear blank"></div>
    @await Html.PartialAsync("Sides/_RandomListPartial")
    <div class="clear blank"></div>
    <environment names="Production">
        @*@await Html.PartialAsync("Ads/_DiaplayPartial")*@
    </environment>

</aside>